package com.minedata.authorization.service;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;

import com.minedata.authorization.bean.UserBean;
import com.minedata.authorization.mapper.UserMapper;


@Service
@ComponentScan(basePackages = {"com.minedata.authorization.mapper"})
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;
	
	/**
	 * 根据账号id查询当前用户
	 * @param id
	 * @return
	 */
	public UserBean findById(Integer id) {
		return userMapper.findById(id);
	}

	/**
	 * 根据账号username查询当前用户
	 * @param username
	 * @return
	 */
	public UserBean findByUsername(String username) {
		return userMapper.findByUsername(username);
	}

	/**
	 * 获取资源集合
	 * @param account
	 * @return
	 */
	public Set<String> findPermissions(String account) {
//		Set<String> set = Sets.newHashSet();
//		UserBean user = findByAccount(account);
//		List<ModuleBean>modules = moduleService.findModuleByUserId(user.getId());
//		
//		for(ModuleBean info: modules) {
//			set.add(info.getModuleKey());
//		}
		return null;
	}

	/**
	 * 获取URL权限
	 * @param account
	 * @return
	 */
	public List<String> findPermissionUrl(String account) {
//		List<String> list = Lists.newArrayList();
//		UserBean user = findByAccount(account);
//		List<ModuleInfo>modules = moduleService.findModuleByUserId(user.getId());
//		
//		for(ModuleInfo info: modules) {
//			if(info.getModuleType() == ModuleInfo.URL_TYPE) {
//				list.add(info.getModulePath());
//			}
//		}
		return null;
	}
}